<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="项目编号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="建档日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="执行状态">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="项目名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   disabled/>
          </el-form-item>
         </el-col>

          <el-col :span="8">
            <el-form-item label="所属院系">
              <el-select v-model="dataForm.FHOME" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="课 题 组">
              <el-select v-model="dataForm.FGROUP" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value" disabled>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="进度编号" prop="FCATNO">
            <el-input v-model="dataForm.FCATNO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="开始日期" prop="FBEGDATE">
            <el-date-picker v-model="dataForm.FBEGDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
        </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="结束日期" prop="FENDDATE">
            <el-date-picker v-model="dataForm.FENDDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
        </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="进度名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="进度费用" prop="FMONEY">
            <el-input v-model="dataForm.FMONEY"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="人力安排" prop="FNUM">
            <el-input v-model="dataForm.FNUM"   />
          </el-form-item>
        </el-col>


        <el-col :span="16">
          <el-form-item label="进度介绍" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>
        
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="活动列表" name="first">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-edit" style="color: red" @click="shopdate(scope.$index)"
                type="text">编辑</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
          <el-table-column prop="FWORKNO" label="活动编号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="活动名称"></el-table-column>
          <!-- <el-table-column prop="FBEGDATE" label="开始日期" width="95"></el-table-column> -->
          <!-- <el-table-column prop="FENDDATE" label="结束活动" width="95"></el-table-column> -->
          <el-table-column prop="FBEGDATE2" label="实际起日" width="95"></el-table-column>
          <el-table-column prop="FENDDATE2" label="实际讫日" width="95"></el-table-column>
          <el-table-column prop="FMONEY2" label="实际费用(AC)" width="95"></el-table-column>
          <el-table-column prop="FMONEY" label="完成费用(EV)" width="95"></el-table-column>
          <el-table-column prop="FRATE" label="完成百分比%" width="95"></el-table-column>
          <!-- <el-table-column prop="FPCAT" label="上一活动" width="95"></el-table-column> -->
          <!-- <el-table-column prop="FNCAT" label="下一活动" width="95"></el-table-column> -->
       </el-table>
      </el-tab-pane>

      <el-tab-pane label="项目成员" name="five">
        <el-table :data="list5" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="人员编号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="人员姓名"></el-table-column>
          <el-table-column prop="FWORKFLAG" label="职责"></el-table-column>
          <el-table-column prop="FMEMO" label="备注信息" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

      <el-tab-pane label="设备清单" name="second">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FEQUIPNO" label="设备编号" ></el-table-column>
          <el-table-column prop="FEQUIPNAME" label="设备名称"></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>
      
      <el-tab-pane label="危化品清单" name="third">
        <el-table :data="list3" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="危化品名称" ></el-table-column>
          <el-table-column prop="FCAS" label="CAS号"></el-table-column>
          <el-table-column prop="FQTY" label="用量" ></el-table-column>
          <el-table-column prop="FUNIT" label="单位" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

      <el-tab-pane label="耗材清单" name="fourth">
        <el-table :data="list4" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">编辑</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="耗材编号"></el-table-column>
          <el-table-column prop="FWORKNAME" label="耗材名称" ></el-table-column>
          <el-table-column prop="FQTY" label="数量" ></el-table-column>
          <el-table-column prop="FUNIT" label="单位" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注" ></el-table-column>
        </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

    </el-tabs>
  </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
            FBILLNO: "K241130001", 
            FBILLCREDATE:"2024-11-03",
            FHOME:"化学与材料科学学院",
            FUSER:"曹操",
            FITEMNAME:"医疗垃圾智慧处理系统",
            FCATNO:"第一阶段",
            FCATNAME:"环境准备,设备到位,培训完成",
            FNUM:5,
            FTEACH:"秦始皇",
            FWEEK:"1个月",
            FBEGDATE:"2025-02-01",
            FENDDATE:"2025-02-28",
            FMONEY:"3万",
            FBILLSTATE:"执行中"
        },
        rules: {
          FGROUP:[
            { required: true, message: '请选择课题组', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FCATNAME: [
            { required: true, message: '请输入项目名称', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FEQUIPNO": "98001",
                  "FEQUIPNAME": "通风柜1-1"
                },
                { "FENTRYID":2,
                  "FEQUIPNO": "98002",
                  "FEQUIPNAME": "通风柜1-2"
                }],
        list2: [{  "FENTRYID":1,
                    "FWORKNO": "1-1",
                    "FWORKNAME": "环境准备",
                    "FBEGDATE":"2025-02-01",
                    "FENDDATE":"2025-02-07",
                    "FMONEY":"0.5万",
                    "FMEMO": "人、财、物到齐",
                    "FPCAT":"",
                    "FNCAT":"设备到位",
                    "FNUM":2,
                    "FBEGDATE2":"2025-02-01",
                    "FENDDATE2":"2025-02-07",
                    "FMONEY2":"0.5万",
                    "FNUM2":2,
                    "FRATE":"100"
                  },
                  { "FENTRYID":2,
                    "FWORKNO": "1-2",
                    "FWORKNAME": "设备到位",
                    "FBEGDATE":"2025-02-08",
                    "FENDDATE":"2025-02-20",
                    "FMONEY":"2万",
                    "FMEMO": "集中办公",
                    "FPCAT":"环境准备",
                    "FNCAT":"培训完成",
                    "FNUM":2,
                    "FBEGDATE2":"2025-02-08",
                    "FENDDATE2":"2025-02-20",
                    "FMONEY2":"2万",
                    "FNUM2":2,
                    "FRATE":"100"
                  },
                  { "FENTRYID":3,
                    "FWORKNO": "1-3",
                    "FWORKNAME": "培训完成",
                    "FBEGDATE":"2025-02-21",
                    "FENDDATE":"2025-02-28",
                    "FMONEY":"0.5万",
                    "FMEMO": "文档编写一并进行",
                    "FPCAT":"设备到位",
                    "FNCAT":"",
                    "FNUM":1,
                    "FBEGDATE2":"2025-02-21",
                    "FENDDATE2":"2025-02-28",
                    "FMONEY2":"0.5万",
                    "FNUM2":1,
                    "FRATE":"100"
                  }],
        list3: [{ "FENTRYID":1,
                  "FWORKNAME": "二乙基镁",
                  "FCAS": "557-18-6",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FWORKNAME": "硫氰酸",
                  "FCAS": "463-56-9",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FWORKNAME": "甲酸乙烯酯",
                  "FCAS": "692-45-5",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                }],

        list4: [{  "FENTRYID":1,
                    "FWORKNO": "200001",
                    "FWORKNAME": "医用口罩",
                    "FQTY":"5",
                    "FUNIT":"个",
                    "FMEMO": ""
                  },
                  { "FENTRYID":2,
                    "FWORKNO": "20002",
                    "FWORKNAME": "医用手套",
                    "FQTY":"5",
                    "FUNIT":"个",
                    "FMEMO": ""
                  }],
        list5: [{ "FENTRYID":1,
                  "FWORKNO": "1002",
                  "FWORKNAME": "曹洪",
                  "FUFWORKFLAGNIT":"操作手",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FWORKNO": "1003",
                  "FWORKNAME": "曹丕",
                  "FUFWORKFLAGNIT":"操作手",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '申请中'
        }, {
          value: '2',
          label: '已通过'
        }, {
          value: '3',
          label: '已驳回'
        }],

        options4: [{
          value: '1',
          label: '化学系'
        }, {
          value: '2',
          label: '分析测试中心'
        }, {
          value: '8',
          label: '食品安全与检测'
        }],

        //所属校区选择数据
        options3: [{
          value: '1',
          label: '秦始皇'
        }, {
          value: '2',
          label: '汉武帝'
        }, {
          value: '3',
          label: '唐太宗'
        }],

        options4: [{
          value: '1',
          label: '化学与材料科学学院'
        }, {
          value: '2',
          label: '生命科学学院'
        }],

        options5: [{
          value: '1',
          label: '本科'
        }, {
          value: '2',
          label: '研究生'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>